<?php

namespace App\Module\Api\Controllers;
use App\Module\Api\Validator\UserListValidator;
use App\System\Base\Repositories\BaseNotificationRecordRepository;
use App\System\Base\Services\TokenService;
use App\System\Cis\Repositories\CisUserRepository;

/**
 * Class UserController 主页
 * @package App\Module\Admin\Controllers
 */
class UserListController extends Controller
{
    //主页
    public function index()
    {
        (new UserListValidator())->check();
        $action = $this->query->action;
        $user = CisUserRepository::getInstance();
        if($action == 1)
        {//我的创客账号
            $masterId = TokenService::getMasterId();
            $data = $user->getUserList($this->table,$masterId);
            $number = BaseNotificationRecordRepository::getInstance()->getUnreadNumber($masterId);
            $data = array_merge($data,$number);
        }
        else
        {//我的用户
            $user_id = TokenService::getUserId();
            $data = $user->getUserList($this->table,0,$user_id);
        }
        return apiResponse($data);
    }
}
